package com.example.mapstructdemo;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;


/**
 * mapper可以进行字段映射，改变字段类型，指定格式化的方式，包括一些日期的默认处理
 */
@Mapper
public interface Student2Mapper {

    Student2Mapper INSTANCE = Mappers.getMapper(Student2Mapper.class);

    @Mapping(source = "gender", target = "gender")
    @Mapping(source = "birthday", target = "birthday", dateFormat = "yyyy-MM-dd HH:mm:ss")
    StudentVO student2StudentVO(Student student);

    default String getGenderName(GenderEnum gender) {
        return gender.getName();
    }
}
